jQuery(document).ready(function() {
	
	initTable();
	
	$('#search').click(function(){
		$('#questionsTable').bootstrapTable(('refresh'));
	});
});

function initTable(){	
	
	$('#questionsTable').bootstrapTable({
		method: 'post',
	    url: projectPath + 'questions/list.do',
	    pagination: true, //分页
	    dataType: "json",
        contentType: "application/json",
        pageList: [10, 20, 50, 100],  //可供选择的每页的行数（*）
        striped: true,      //是否显示行间隔色
        sidePagination: "server",
        ////查询参数,每次调用是会带上这个参数，可自定义                         
        queryParams:function(params) {
            return {
            	pageNum: params.offset / params.limit + 1,
            	pageSize: params.limit,
            	title: $('#title').val(),
            	status: '1'
            };
        },
	    columns: [{
            field : 'number',  
            title : '序号',  
            align : 'center',
            width : '80px',
            formatter : function(value, row, index) {
                var page = $('#questionsTable').bootstrapTable("getPage");  
                return page.pageSize * (page.pageNumber - 1) + index + 1;
            }
	    }, {
	        field: 'title',
	        title: '标题',
	        formatter : function(value, row, index) {
	        	return ['<a href="detail.html?questionsId=' + row.questionsId + '" >' + row.title + '</a>'].join('');
	        }
	    }]
	});
}